/**
 * <copyright>
 * </copyright>
 *
 * $Id: EntityBeanImpl.java,v 1.1 2008/11/09 03:11:52 song Exp $
 */
package cn.edu.pku.sei.ra.wrapping.JOnAS.impl;

import cn.edu.pku.sei.ra.wrapping.JOnAS.EntityBean;
import cn.edu.pku.sei.ra.wrapping.JOnAS.JOnASPackage;

import cn.edu.pku.sei.ra.wrapping.JOnAS.MBeanServer;
import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.ecore.EClass;

import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.util.EcoreUtil;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Entity Bean</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link cn.edu.pku.sei.ra.wrapping.JOnAS.impl.EntityBeanImpl#getPassivationTimeOut <em>Passivation Time Out</em>}</li>
 *   <li>{@link cn.edu.pku.sei.ra.wrapping.JOnAS.impl.EntityBeanImpl#getInactivityTimeOut <em>Inactivity Time Out</em>}</li>
 *   <li>{@link cn.edu.pku.sei.ra.wrapping.JOnAS.impl.EntityBeanImpl#getDeadlockTimeOut <em>Deadlock Time Out</em>}</li>
 *   <li>{@link cn.edu.pku.sei.ra.wrapping.JOnAS.impl.EntityBeanImpl#getLockPolicy <em>Lock Policy</em>}</li>
 *   <li>{@link cn.edu.pku.sei.ra.wrapping.JOnAS.impl.EntityBeanImpl#getParent <em>Parent</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class EntityBeanImpl extends EJBImpl implements EntityBean {
	/**
	 * The default value of the '{@link #getPassivationTimeOut() <em>Passivation Time Out</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getPassivationTimeOut()
	 * @generated
	 * @ordered
	 */
	protected static final int PASSIVATION_TIME_OUT_EDEFAULT = 0;

	/**
	 * The cached value of the '{@link #getPassivationTimeOut() <em>Passivation Time Out</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getPassivationTimeOut()
	 * @generated
	 * @ordered
	 */
	protected int passivationTimeOut = PASSIVATION_TIME_OUT_EDEFAULT;

	/**
	 * The default value of the '{@link #getInactivityTimeOut() <em>Inactivity Time Out</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getInactivityTimeOut()
	 * @generated
	 * @ordered
	 */
	protected static final int INACTIVITY_TIME_OUT_EDEFAULT = 0;

	/**
	 * The cached value of the '{@link #getInactivityTimeOut() <em>Inactivity Time Out</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getInactivityTimeOut()
	 * @generated
	 * @ordered
	 */
	protected int inactivityTimeOut = INACTIVITY_TIME_OUT_EDEFAULT;

	/**
	 * The default value of the '{@link #getDeadlockTimeOut() <em>Deadlock Time Out</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getDeadlockTimeOut()
	 * @generated
	 * @ordered
	 */
	protected static final int DEADLOCK_TIME_OUT_EDEFAULT = 0;

	/**
	 * The cached value of the '{@link #getDeadlockTimeOut() <em>Deadlock Time Out</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getDeadlockTimeOut()
	 * @generated
	 * @ordered
	 */
	protected int deadlockTimeOut = DEADLOCK_TIME_OUT_EDEFAULT;

	/**
	 * The default value of the '{@link #getLockPolicy() <em>Lock Policy</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getLockPolicy()
	 * @generated
	 * @ordered
	 */
	protected static final String LOCK_POLICY_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getLockPolicy() <em>Lock Policy</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getLockPolicy()
	 * @generated
	 * @ordered
	 */
	protected String lockPolicy = LOCK_POLICY_EDEFAULT;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected EntityBeanImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return JOnASPackage.Literals.ENTITY_BEAN;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public int getPassivationTimeOut() {
		return passivationTimeOut;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setPassivationTimeOut(int newPassivationTimeOut) {
		int oldPassivationTimeOut = passivationTimeOut;
		passivationTimeOut = newPassivationTimeOut;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, JOnASPackage.ENTITY_BEAN__PASSIVATION_TIME_OUT, oldPassivationTimeOut, passivationTimeOut));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public int getInactivityTimeOut() {
		return inactivityTimeOut;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setInactivityTimeOut(int newInactivityTimeOut) {
		int oldInactivityTimeOut = inactivityTimeOut;
		inactivityTimeOut = newInactivityTimeOut;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, JOnASPackage.ENTITY_BEAN__INACTIVITY_TIME_OUT, oldInactivityTimeOut, inactivityTimeOut));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public int getDeadlockTimeOut() {
		return deadlockTimeOut;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setDeadlockTimeOut(int newDeadlockTimeOut) {
		int oldDeadlockTimeOut = deadlockTimeOut;
		deadlockTimeOut = newDeadlockTimeOut;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, JOnASPackage.ENTITY_BEAN__DEADLOCK_TIME_OUT, oldDeadlockTimeOut, deadlockTimeOut));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getLockPolicy() {
		return lockPolicy;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setLockPolicy(String newLockPolicy) {
		String oldLockPolicy = lockPolicy;
		lockPolicy = newLockPolicy;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, JOnASPackage.ENTITY_BEAN__LOCK_POLICY, oldLockPolicy, lockPolicy));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public MBeanServer getParent() {
		if (eContainerFeatureID != JOnASPackage.ENTITY_BEAN__PARENT) return null;
		return (MBeanServer)eContainer();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetParent(MBeanServer newParent, NotificationChain msgs) {
		msgs = eBasicSetContainer((InternalEObject)newParent, JOnASPackage.ENTITY_BEAN__PARENT, msgs);
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setParent(MBeanServer newParent) {
		if (newParent != eInternalContainer() || (eContainerFeatureID != JOnASPackage.ENTITY_BEAN__PARENT && newParent != null)) {
			if (EcoreUtil.isAncestor(this, newParent))
				throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
			NotificationChain msgs = null;
			if (eInternalContainer() != null)
				msgs = eBasicRemoveFromContainer(msgs);
			if (newParent != null)
				msgs = ((InternalEObject)newParent).eInverseAdd(this, JOnASPackage.MBEAN_SERVER__ENTITY_BEAN, MBeanServer.class, msgs);
			msgs = basicSetParent(newParent, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, JOnASPackage.ENTITY_BEAN__PARENT, newParent, newParent));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case JOnASPackage.ENTITY_BEAN__PARENT:
				if (eInternalContainer() != null)
					msgs = eBasicRemoveFromContainer(msgs);
				return basicSetParent((MBeanServer)otherEnd, msgs);
		}
		return super.eInverseAdd(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case JOnASPackage.ENTITY_BEAN__PARENT:
				return basicSetParent(null, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) {
		switch (eContainerFeatureID) {
			case JOnASPackage.ENTITY_BEAN__PARENT:
				return eInternalContainer().eInverseRemove(this, JOnASPackage.MBEAN_SERVER__ENTITY_BEAN, MBeanServer.class, msgs);
		}
		return super.eBasicRemoveFromContainerFeature(msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case JOnASPackage.ENTITY_BEAN__PASSIVATION_TIME_OUT:
				return new Integer(getPassivationTimeOut());
			case JOnASPackage.ENTITY_BEAN__INACTIVITY_TIME_OUT:
				return new Integer(getInactivityTimeOut());
			case JOnASPackage.ENTITY_BEAN__DEADLOCK_TIME_OUT:
				return new Integer(getDeadlockTimeOut());
			case JOnASPackage.ENTITY_BEAN__LOCK_POLICY:
				return getLockPolicy();
			case JOnASPackage.ENTITY_BEAN__PARENT:
				return getParent();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case JOnASPackage.ENTITY_BEAN__PASSIVATION_TIME_OUT:
				setPassivationTimeOut(((Integer)newValue).intValue());
				return;
			case JOnASPackage.ENTITY_BEAN__INACTIVITY_TIME_OUT:
				setInactivityTimeOut(((Integer)newValue).intValue());
				return;
			case JOnASPackage.ENTITY_BEAN__DEADLOCK_TIME_OUT:
				setDeadlockTimeOut(((Integer)newValue).intValue());
				return;
			case JOnASPackage.ENTITY_BEAN__LOCK_POLICY:
				setLockPolicy((String)newValue);
				return;
			case JOnASPackage.ENTITY_BEAN__PARENT:
				setParent((MBeanServer)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case JOnASPackage.ENTITY_BEAN__PASSIVATION_TIME_OUT:
				setPassivationTimeOut(PASSIVATION_TIME_OUT_EDEFAULT);
				return;
			case JOnASPackage.ENTITY_BEAN__INACTIVITY_TIME_OUT:
				setInactivityTimeOut(INACTIVITY_TIME_OUT_EDEFAULT);
				return;
			case JOnASPackage.ENTITY_BEAN__DEADLOCK_TIME_OUT:
				setDeadlockTimeOut(DEADLOCK_TIME_OUT_EDEFAULT);
				return;
			case JOnASPackage.ENTITY_BEAN__LOCK_POLICY:
				setLockPolicy(LOCK_POLICY_EDEFAULT);
				return;
			case JOnASPackage.ENTITY_BEAN__PARENT:
				setParent((MBeanServer)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case JOnASPackage.ENTITY_BEAN__PASSIVATION_TIME_OUT:
				return passivationTimeOut != PASSIVATION_TIME_OUT_EDEFAULT;
			case JOnASPackage.ENTITY_BEAN__INACTIVITY_TIME_OUT:
				return inactivityTimeOut != INACTIVITY_TIME_OUT_EDEFAULT;
			case JOnASPackage.ENTITY_BEAN__DEADLOCK_TIME_OUT:
				return deadlockTimeOut != DEADLOCK_TIME_OUT_EDEFAULT;
			case JOnASPackage.ENTITY_BEAN__LOCK_POLICY:
				return LOCK_POLICY_EDEFAULT == null ? lockPolicy != null : !LOCK_POLICY_EDEFAULT.equals(lockPolicy);
			case JOnASPackage.ENTITY_BEAN__PARENT:
				return getParent() != null;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (passivationTimeOut: ");
		result.append(passivationTimeOut);
		result.append(", inactivityTimeOut: ");
		result.append(inactivityTimeOut);
		result.append(", deadlockTimeOut: ");
		result.append(deadlockTimeOut);
		result.append(", lockPolicy: ");
		result.append(lockPolicy);
		result.append(')');
		return result.toString();
	}
	
	public boolean isForCore(Object obj){
		if(core!=null && core.equals(obj))
			return true;
		return false;
	}

} //EntityBeanImpl
